package fr.afcepf.atod20.organismedeformation.data;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.sql.DataSource;


/**
 * DataSource pour se connecter � la BDD 'organisme_formation'.
 * 
 * @author stagiaire
 * 
 */
public class DataSourceAtod20 implements DataSource {

    /**
     * logger.
     */
    private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(DataSourceAtod20.class);

    @Override
    public Connection getConnection() throws SQLException {
        Connection cnx = null;
        ResourceBundle resources =
                ResourceBundle.getBundle("db");
        try {
            Class.forName(resources.getString("jdbcDriver"));
            cnx = DriverManager.getConnection(
                    resources.getString("url"),
                    resources.getString("username"),
                    resources.getString("password")
                    );
        } catch (ClassNotFoundException | SQLException e) {
            log.error("ERROR getConnection : ", e);
        }
        return cnx;
    }

    @Override
    public PrintWriter getLogWriter() throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setLogWriter(PrintWriter paramArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    @Override
    public void setLoginTimeout(int paramArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean isWrapperFor(Class<?> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public <T> T unwrap(Class<T> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Connection getConnection(String paramArg0, String paramArg1) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

}
